package com.cx.util;

import com.sun.deploy.config.Platform;
import com.sun.deploy.util.JarUtil;

import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.jar.JarFile;

/**
 * @author cxx
 * @create 2020-11-06 11:09
 **/
public class FileUtil {

    public static File getClassPathFile(String path) {

        ClassLoader loader = FileUtil.class.getClassLoader ();
        System.out.println (loader);
        URL url = loader.getResource (path);
        if(url == null){
            System.out.println ("url==null");
            return null;
        }
        File file = null;
        try {
            file = new File (url.toURI ());
        } catch (URISyntaxException e) {
            e.printStackTrace ();
        }
        return file;
    }

    public static void main(String[] args) {
        File file = getClassPathFile ("test.properties");
        System.out.println (file.getName ());
    }

}
